package com.cherrish.demo.thread;

import java.util.concurrent.CountDownLatch;

/**
 * @author cherrish
 * @time 2019-03-04 10:50
 * @name TestPlusPlus
 * @desc:
 */
public class TestPlusPlus {
    static int count = 0;
    static CountDownLatch latch = new CountDownLatch(1000);

    public static void main(String[] args) throws InterruptedException {
        PlusRunable plus = new PlusRunable();
        for(int i = 0; i < 1000; i++){
            new Thread(plus).start();
        }
        latch.await();
        System.out.println(count);
    }

    static class PlusRunable implements Runnable{

        private void count(){
            for(int i = 0; i < 1000; i++){
                count++;
            }
        }
        @Override
        public void run() {
            count();
            latch.countDown();
        }
    }
}
